import mx.containers.Box;
import mx.effects.EffectInstance;

/**
 * Custom padding effect instance which plays bottom and top paddings from some padding to zero.
 */
public class PaddingEffectInstance extends EffectInstance
{
	/**
	 * The padding from which we want to play the event to zero.
	 */
	public var paddingFrom:Number;
	
	/**
	 * Constructor. Must accept a parameter to pass to the <code>EffectInstance</code>
	 */
	public function PaddingEffectInstance(target:Object)
	{
		super(target);
	}
	
	/**
	 * Sets the padding top and bottom to zero.
	 */
	override public function play():void
	{
		super.play();
		
		target.setStyle("paddingTop", 0);
		target.setStyle("paddingBottom", 0);
		target.setStyle("paddingLeft", 0);
		target.setStyle("paddingRight", 0);
	}
	
	/**
	 * Reverts the padding top and bottom values to <code>paddingFrom</code>
	 */
	override public function reverse():void
	{
		super.reverse();
		
		target.setStyle("paddingTop", paddingFrom.toString());
		target.setStyle("paddingBottom", paddingFrom.toString());
		target.setStyle("paddingLeft", paddingFrom.toString());
		target.setStyle("paddingRight", paddingFrom.toString());
	}
}
}